New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

jewish-dates-core

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jewish-dates-core

Jewish dates core

  • 1.2.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
246
decreased by-8.89%
Maintainers
1
Weekly downloads
 
Created
Source

jewish-dates-core

This package is core functionality of react-jewish-datepicker

If you want to create a jewish date picker in vue.js or angular, this is the core dependency.

Installation

yarn add jewish-dates-core

Or with npm

npm i jewish-dates-core --save

Functions

isValidDate

Returns whether a date is a Date object

isMeubar

Returns whether a hebrew year is meubar (leap year)

getHebWeekdays

Returns an array of week days in hebrew

getEngWeekdays

Returns an array of week days in english

getWeekdays

Returns an array of week days

convertToHebrew

Converts a numerical value to a string of Hebrew letters (gematriya)

getHebJewishMonthById

Takes a jewish month name in english and returns the name in hebrew

getHebJewishMonths

Returns an array of jewish months in hebrew

getEngJewishMonths

Returns an array of jewish months in english

getJewishMonths

Returns an array of jewish months according to year and language

getJewishYears

Takes a number of a jewish year and returns array of 200 years around it

getPrevMonth

Takes a BasicJewishMonthInfo object and returns the equivalent of prev month

getNextMonth

Takes a BasicJewishMonthInfo object and returns the equivalent of next month

getGregDate

Converts BasicJewishDate object to gregorian date

getJewishMonthInfo

Takes a gregorian date and returns BasicJewishMonthInfo object

formatJewishDate

Takes a BasicJewishDate object and returns a string of the date in english

formatJewishDateHebrew

Takes a BasicJewishDate object and returns a string of the date in hebrew

getJewishDate

Takes a gregorian date and returns a BasicJewishDate object

IsJewishDatesEqual

Compares jewish dates returning true if the dates match and false if not

getJewishDay

Takes a dayjs date and returns a JewishDay object

getJewishMonth

Takes a gregorian date and returns a JewishMonth object

getHolidays

Returns an array of jewish holiday dates corresponding with the isIsrael param

dontSelectHolidays

Returns a function which can be passed to the `canSelect` prop, in order to prevent holidays selection

dontSelectShabat

A function to be passed to the "canSelect" prop, in order to prevent shabat selection

dontSelectShabatAndHolidays

Returns a function to be passed to the "canSelect" prop. combines "dontSelectHolidays" and "dontSelectShabat" in order to prevent both - shabat and holidays selection

dontSelectOutOfRange

Takes min date and max date and returns a function to be passed to the "canSelect" prop, in order to prevent selection out of the supplied range

addDates

Adds days to a given date

subtractDates

Subtracts days to a given date

isValidDate(date: Date | BasicJewishDate) ⇒ boolean

Returns whether a date is a Date object.

ParamType
dateDate | BasicJewishDate

example:

const basicJewishDate: BasicJewishDate = {
  day: 13,
  monthName: "Elul",
  year: 5788,
};

isValidDate(basicJewishDate); // ==> false
isValidDate(new Date()); // ==> true

isMeubar(year: number) ⇒ boolean

Returns whether a hebrew year is meubar (leap year).

ParamType
yearnumber

example:

isMeubar(5781); // ==> false
isMeubar(5782); // ==> true

getHebWeekdays() ⇒ string[]

Returns an array of week days in hebrew.

example:

getHebWeekdays(); // ==> ["א", "ב", "ג", "ד", "ה", "ו", "ש"]

getEngWeekdays() ⇒ string[]

Returns an array of week days in english.

example:

getEngWeekdays(); // ==> ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]

getWeekdays(isHebrew: boolean) ⇒ string[]

Returns an array of week days corresponding with the isHebrew param.

ParamType
isHebrewboolean

example:

getWeekdays(true); // ==> ["א", "ב", "ג", "ד", "ה", "ו", "ש"]
getWeekdays(false); // ==> ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]

convertToHebrew(num: number, [addGeresh: boolean, addPunctuate: boolean]) ⇒ string

Converts a numerical value to a string of Hebrew letters (gematriya).

Based on gematriya library:

Setting false as the value for the punctuate key will remove double and single quotation marks in the returned string. Setting geresh to false will use ASCII single/double quotes instead of Hebrew geresh/gershayim Unicode characters. (see example bellow)

ParamTypeDefault
numnumbern/a
addGereshbooleantrue
addPunctuatebooleantrue

example:

convertToHebrew(5782); // ==> 'תשפ״ב'
convertToHebrew(5782, false); // ==> 'תשפ"ב'
convertToHebrew(5782, false, false); // ==> 'תשפב'

getHebJewishMonthById(monthId: string) ⇒ string

Takes a jewish month name in english and returns the name in hebrew.

ParamType
monthIdstring

example:

getHebJewishMonthById("Tishri"); // ==> 'תשרי'

getHebJewishMonths() ⇒ IdText[]

Returns an array of jewish months in hebrew.

example:

getHebJewishMonths(); // ==> [{id: "Tishri", text: "תשרי"}, {id: "Heshvan", text: "חשון"} ...]

getEngJewishMonths() ⇒ IdText[]

Returns an array of jewish months in english.

example:

getEngJewishMonths(); // ==> [{id: "Tishri", text: "Tishri"}, {id: "Heshvan", text: "Heshvan"} ...]

getJewishMonths(year: number, [isHebrew?: boolean]) ⇒ IdText[]

Returns an array of jewish months according to year (regular/leap) and language.

ParamTypeDefault
yearnumbern/a
isHebrewbooleanfalse

example:

getJewishMonths(5781, true); // ==> [... {id: "AdarI", text: "אדר"}, {id: "Nisan", text: "ניסן"} ...] regular year months in henrew
getJewishMonths(5782); // ==> [... {id: "AdarI", text: "AdarI"}, {id: "AdarII", text: "AdarII"} ...] leap year months in english

getJewishYears(year: number) ⇒ number[]

Takes a number of a jewish year and returns array of 200 years around it.

ParamType
yearnumber

example:

getJewishYears(5781); // ==> [5681, 5682, ... 5781, ... 5880, 5881]
getJewishYears(5781).length; // ==> 201

getPrevMonth(basicJewishMonthInfo: BasicJewishMonthInfo) ⇒ BasicJewishMonthInfo

Takes a BasicJewishMonthInfo object and returns the equivalent of prev month.

ParamType
basicJewishMonthInfoBasicJewishMonthInfo

example:

const tishriInfo: BasicJewishMonthInfo = {
  isHebrew: false,
  month: "Tishri",
  year: 5782,
};

getPrevMonth(tishriInfo); // ==> {isHebrew: false, month: 'Elul', year: 5781}

getNextMonth(basicJewishMonthInfo: BasicJewishMonthInfo) ⇒ BasicJewishMonthInfo

Takes a BasicJewishMonthInfo object and returns the equivalent of next month.

ParamType
basicJewishMonthInfoBasicJewishMonthInfo

example:

const elulInfo: BasicJewishMonthInfo = {
  isHebrew: true,
  month: "Elul",
  year: 5781,
};

getNextMonth(elulInfo); // ==> {isHebrew: true, month: 'Tishri', year: 5782}

getGregDate(props: BasicJewishDate) ⇒ Date

Converts BasicJewishDate object to gregorian date.

ParamType
propsBasicJewishDate

example:

const basicJewishDate: BasicJewishDate = {
  day: 13,
  monthName: "Elul",
  year: 5781,
};

getGregDate(basicJewishDate); // ==> Sat Aug 21 2021 00:00:00 GMT+0300 (שעון ישראל (קיץ))

getJewishMonthInfo(date: Date) ⇒ JewishMonthInfo

Takes a gregorian date and returns BasicJewishMonthInfo object.

ParamType
dateDate

example:

getJewishMonthInfo(new Date(2022, 0, 27)); /* ==> { jewishDate: {year: 5782, month: 5, day: 25, monthName: 'Shevat'},
                                                    jewishMonth: 5,
                                                    startOfJewishMonth: Dayjs(new Date(2022, 0, 3)),
                                                    sundayStartOfTheMonth: Dayjs(new Date(2022, 0, 2))} */

formatJewishDate(jewishDate: JewishDate) ⇒ string

Takes a BasicJewishDate object and returns a string of the date in english.

ParamType
jewishDateJewishDate

example:

const jewishDate: JewishDate = {
  day: 13,
  monthName: "Elul",
  year: 5781,
  month: 13,
};

formatJewishDate(jewishDate); // ==> "13 Elul 5781"

formatJewishDateHebrew(jewishDate: JewishDate) ⇒ string

Takes a BasicJewishDate object and returns a string of the date in hebrew.

ParamType
jewishDateJewishDate

example:

const jewishDate: JewishDate = {
  day: 13,
  monthName: "Elul",
  year: 5781,
  month: 13,
};

formatJewishDateHebrew(jewishDate); // ==> "י״ג אלול התשפ״א"

getJewishDate(date: Date) ⇒ JewishDate

Takes a gregorian date and returns a BasicJewishDate object.

ParamType
dateDate

example:

getJewishDate(new Date(2021, 7, 21)); // ==> {day: 13, monthName: "Elul", year: 5781, month: 13}

IsJewishDatesEqual(jewishDate1: JewishDate, jewishDate2: JewishDate) ⇒ boolean

Compares jewish dates returning true if the dates match and false if not.

ParamType
jewishDate1JewishDate
jewishDate2JewishDate

example:

const jewishDate1: JewishDate = {
  day: 13,
  monthName: "Elul",
  year: 5781,
  month: 13,
};
const jewishDate2: JewishDate = {
  day: 14,
  monthName: "Shevat",
  year: 5781,
  month: 5,
};

IsJewishDatesEqual(jewishDate1, jewishDate2); // ==> false
IsJewishDatesEqual(jewishDate2, jewishDate2); // ==> true

getJewishDay(dayjsDate: Dayjs) ⇒ JewishDay

Takes a gregorian date and returns a JewishMonth object.

ParamType
dayjsDateDayjs

example:

const date = Dayjs(new Date(2022, 0, 27));

getJewishDay(date); /* ==> { date: 2022-01-26T22:00:00.000Z,
                             day: 25,
                             dayjsDate: d {'$L': 'en', '$d': 2022-01-26T22:00:00.000Z, '$y': 2022, '$M': 0, '$D': 27, '$W': 4, '$H': 0, '$m': 0, '$s': 0, '$ms': 0},
                             isCurrentMonth: false,
                             jewishDate: { year: 5782, month: 5, day: 25, monthName: 'Shevat' },
                             jewishDateStr: '25 Shevat 5782',
                             jewishDateStrHebrew: 'כ״ה שבט התשפ״ב'} */

getJewishMonth(date: Date) ⇒ JewishMonth

Takes a gregorian date and returns a JewishMonth object.

ParamType
dateDate

example:

getJewishMonth(new Date(2022, 0, 27)); /* ==> selectedDay: { day: 25, jewishDateStr: '25 Shevat 5782', ...},
                                              jewishMonth: 5,
                                              jewishYear: 5782,
                                              jewishMonthString: 'Shevat',
                                              days: [{day: 29, jewishDateStr: '29 Tevet 5782', ...}, { day: 1, jewishDateStr: '1 Shevat 5782', ...}, ...] */

getHolidays(isIsrael: boolean) ⇒ string[]

Returns an array of jewish holiday dates corresponding with the isIsrael param.

ParamType
isIsraelboolean

example:

getHolidays(true); // ==> ['1 Tishri', '2 Tishri', '10 Tishri', '15 Tishri', '22 Tishri', '15 Nisan', '21 Nisan', '6 Sivan']
getHolidays(false); // ==> ['1 Tishri', '2 Tishri', '10 Tishri', '15 Tishri', '22 Tishri', '15 Nisan', '21 Nisan', '6 Sivan', '16 Tishri', '23 Tishri', '16 Nisan', '22 Nisan', '7 Sivan']

dontSelectHolidays([isIsrael: boolean]) ⇒ (day: BasicJewishDay) => boolean

Returns a function which can be passed to the canSelect prop, in order to prevent holidays (corresponding with isIsrael param) selection. The returned function takes a BasicJewishDay object, and returns false if it's an holiday and true otherwise.

ParamTypeDefault
isIsraelbooleanfalse

example: full example here

dontSelectShabat(day: BasicJewishDay) ⇒ boolean

A function to be passed to the canSelect prop, in order to prevent shabat selection. Takes a BasicJewishDay object, and returns false if it's an shabat and true otherwise.

ParamType
dayBasicJewishDay

example: full example here

dontSelectShabatAndHolidays([isIsrael: boolean]) ⇒ (day: BasicJewishDay) => boolean

Returns a function to be passed to the "canSelect" prop. combines dontSelectHolidays and dontSelectShabat in order to prevent both - shabat and holidays selection. The returned function takes a BasicJewishDay object, and returns false if it's an shabat or holiday and true otherwise.

ParamTypeDefault
isIsraelbooleanfalse

example: full example here

dontSelectOutOfRange(minDate: Date | null, maxDate: Date | null) ⇒ (day: BasicJewishDay) => boolean

Takes min date and max date and returns a function to be passed to the "canSelect" prop, in order to prevent selection out of the supplied range. The returned function takes a BasicJewishDay object, and returns true if it's within range (min date and max date included) and false otherwise.

You can pass a date only for one of the params and null to the other. In this case, the selectable range will be up to max date or from min date.

ParamType
minDateDate | null
maxDateDate | null

example: full example here

addDates(date: BasicJewishDate | Date, numDays: number) ⇒ Date

Takes a BasicJewishDate object or a Date, adds a date interval (numDays) to the date and then returns the new date.

ParamType
dateBasicJewishDate | Date
numDaysnumber

example:

const date = new Date(2022, 3, 17);

addDates(date, 3)) // => Wed Apr 20 2022 00:00:00 GMT+0300 (שעון ישראל (קיץ))

subtractDates(date: BasicJewishDate | Date, numDays: number) ⇒ Date

Takes a BasicJewishDate object or a Date, subtracts a date interval (numDays) from the date and then returns the new date.

ParamType
dateBasicJewishDate | Date
numDaysnumber

example:

const basicJewishDate: BasicJewishDate = {
  day: 13,
  monthName: "Elul",
  year: 5781,
};

subtractDates(basicJewishDate, 4)) // => Tue Aug 17 2021 00:00:00 GMT+0300 (שעון ישראל (קיץ))

Keywords

FAQs

Package last updated on 03 Feb 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc